package com.s13.string;

public class BruteForce {
	
	// 拿模式串与主串中是所有子串匹配，看是否有能匹配的子串
	public static boolean isFind(String str, String toFindStr) {
		int n = str.length();
		int m = toFindStr.length();
		
		int i, j;
		for(i = 0; i <= n - m; i ++) {
			boolean isPair = true;
			for (j = 0; j < m; j++) {
				if (toFindStr.charAt(j) != str.charAt(i + j)) {
					isPair = false;
					break;
				}
			}
			if (isPair) {
				System.out.print("position is [" + i +"," + (i + m - 1) + "], ");
				return true;
			}
		}
		return false;
	}

}
